//
//  RadioPageCell.m
//  PetTown
//
//  Created by lanou3g on 15/5/28.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "RadioPageCell.h"
#define LHeight self.contentView.frame.size.height
#define LWidth  self.contentView.frame.size.width
@implementation RadioPageCell



- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpSubViews];
//        self.window.bounds.size.width
    }
    return self;
}


- (void)setUpSubViews{
    //新建左侧img
    self.contentView.frame = CGRectMake(self.contentView.frame.origin.x, self.contentView.frame.origin.y, [UIScreen mainScreen].bounds.size.width, self.contentView.frame.size.height);
    
    self.leftImg = [[UIImageView alloc] init];
    self.leftImg.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:_leftImg];

    //新建右侧label
    self.titleLabel = [[UILabel alloc] init];
    self.unameLabel = [[UILabel alloc] init];
    self.descLabel = [[UILabel alloc] init];
    self.countLabel = [[UILabel alloc] init];
    _unameLabel.textColor = [UIColor brownColor];
    _descLabel.textColor = [UIColor lightGrayColor];
    _unameLabel.alpha = 0.7;
    _countLabel.textColor = [UIColor lightGrayColor];
    _countLabel.font = [UIFont systemFontOfSize:10.0];
    _unameLabel.font = [UIFont systemFontOfSize:10.0];
    _descLabel.font = [UIFont systemFontOfSize:10.0];
    
    
    
    [self.contentView addSubview:_titleLabel];
    [self.contentView addSubview:_unameLabel];
    [self.contentView addSubview:_descLabel];
    [self.contentView addSubview:_countLabel];

}
//添加内容
-(void)setRadioPage:(RadioPage *)radioPage{
    _titleLabel.text = radioPage.title;
    _titleLabel.alpha = 0.7;
    _titleLabel.font = [UIFont systemFontOfSize:14];
    _descLabel.text = radioPage.desc;
    NSString * str = [NSString stringWithFormat:@"%d",radioPage.count];
    _countLabel.text = [NSString stringWithFormat:@"♡ %@",str];
    NSDictionary * dic = radioPage.userinfo;
    _unameLabel.text = [NSString stringWithFormat:@"by: %@",[dic objectForKey:@"uname"]];
    //设置frame
    _leftImg.frame = CGRectMake(10, 10, 80, 80);
    _countLabel.frame = CGRectMake(LWidth - 70, CGRectGetMinY(_leftImg.frame) , 70, 15);
    _titleLabel.frame = CGRectMake(CGRectGetMaxX(_leftImg.frame) + 10, CGRectGetMinY(_leftImg.frame) , LWidth - 180, 20);
    _unameLabel.frame = CGRectMake(CGRectGetMaxX(_leftImg.frame) + 10, CGRectGetMaxY(_titleLabel.frame), LWidth - 110, 15);
    _descLabel.frame = CGRectMake(CGRectGetMaxX(_leftImg.frame) + 10, CGRectGetMaxY(_unameLabel.frame), LWidth - 110, 45);
    _descLabel.numberOfLines = 0;

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
